/*
package cloud.xlh.infrastructure.file.minio.operateimpl;

import cloud.xlh.infrastructure.file.operate.FileOperateService;
import io.minio.MinioClient;
import io.minio.ObjectStat;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.net.URLEncoder;

*/
/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : xlh_osms
 * @ Author: XuLeHuang
 * @ Date: 2022/11/27 12:07
 * @ Description:
 *//*

@Slf4j
@Service("MinIO")
public class MinIOOperateServiceImpl implements FileOperateService {
    @Autowired
    MinioClient minioClient;

    @Override
    public String upload(String fileName, String filePath, String bucketName) {
        try {
            minioClient.putObject(bucketName, fileName, filePath, null);
        } catch (Exception e) {
            log.error("{}上传失败，路径：{}，桶名：{},上传方式：MinIO" ,fileName , filePath , bucketName);
        }
        return fileName;
    }

    @Override
    public void download(String bucketName, String fileName, HttpServletResponse response) {
        // 获取对象的元数据
        try {
            ObjectStat stat = minioClient.statObject(bucketName, fileName);
            response.setContentType(stat.contentType());
            response.setCharacterEncoding("UTF-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
            InputStream is = minioClient.getObject(bucketName, fileName);
            IOUtils.copy(is, response.getOutputStream());
        } catch (Exception e) {
            log.error("{}下载失败，桶名：{},上传方式：MinIO" ,fileName , bucketName);
        }
    }


}
*/
